package com.example.rubbish.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.rubbish.R;

import java.util.List;

public class ViewPagerAdapter extends RecyclerView.Adapter<ViewPagerAdapter.ViewHolder> {



    private List<Integer> imagesIds;

    public ViewPagerAdapter(List<Integer> imagesId){
        this.imagesIds=imagesId;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.banner_item,parent,false));

    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        int i = position % 4;
        holder.imageView.setImageResource(imagesIds.get(i));
//        switch (i) {
//            case WASTE_HAZARDOUS:
//                resourceId = R.drawable.hazardous_waste;
//                break;
//            case WASTE_KITCHEN:
//                resourceId = R.drawable.kitchen_waste;
//                break;
//            case WASTE_OTHER:
//                resourceId = R.drawable.other_waste;
//                break;
//            case WASTE_RECYCLABLE:
//                resourceId = R.drawable.recyclable_waste;
//                break;
//            default:
//                throw new IllegalStateException("Unexpected value: " + i);
//        }

    }//onBindViewHolder

    @Override
    public int getItemCount() {
        //无限播
        return Integer.MAX_VALUE;
    }
    class ViewHolder extends RecyclerView.ViewHolder{
        RelativeLayout container;
        ImageView imageView;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            container=itemView.findViewById(R.id.container);
            imageView=itemView.findViewById(R.id.image_view);
        }
    }
}
